<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    function Animal(name){
        this.name=name;
    }
    Animal.prototype.self =function (){
        console.log('我是一只猫'+this.name);
    }
    var a= new Animal('cat');
    a.self();


    function Person(name){
        this.name=name;
    }
    Person.prototype.sayHello=function(){
        console.log('你好，我是'+this.name);

    }
    var p= new Person('Jim');
    p.sayHello();


    function Student(name){
        this.name=name;
    }
    Student.prototype.sayHello=function(){
        console.log('你好我是'+this.name);

    }
    var s= new Student('学生');
    s.sayHello();


    var s={};
    var p={name:'Jim'};
    s.name= p.name;
    console.log(s.name);

    var p={};
    var a={name:'cat'};
    p.name= a.name;
    console.log(a.name);


</script>

</body>
</html>